package com.orderServlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.order.OrderDao;
import com.vo.Order;

public class OrderModifyServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int flag = 0;
		OrderDao dao = new OrderDao();
		Order order = new Order();
		int id = 0;
		try {
			id = Integer.parseInt(request.getParameter("orderId"));
		} catch (Exception e) {
			// TODO: handle exception
		}
		String name = request.getParameter("name");
		String dress = request.getParameter("dress");
		
		String rDress = new String(dress.getBytes("ISO-8859-1"),"utf-8");
		String username=new String(name.getBytes("ISO-8859-1"),"utf-8");
		
		order.setEo_id(id);
		order.setEo_user_address(rDress);
		order.setEo_user_name(username);
		
		
		try {
			flag = dao.updateOrder(order);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(flag > 0){
			response.sendRedirect("orderViewServlet");
		}else{
			response.sendRedirect("manage/err.jsp");
		}
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
